import { defineConfig } from 'vite'
import { resolve } from 'path'
import vue from '@vitejs/plugin-vue'
import WindiCSS from 'vite-plugin-windicss'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    WindiCSS(),
    AutoImport({
      imports: ['vue'],
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),],
  server: {
    port: 9990,
    proxy: {
      '/prod-api': {
        'target': 'https://bs.gsmba.net',
        'changeOrigin': true
        // rewrite: (path) => path.replace(/^\/stage-api/, '')
      },
      '/stage-api': {
        'target': 'http://192.168.1.251:9081',
        'changeOrigin': true
        // rewrite: (path) => path.replace(/^\/stage-api/, '')
      }
    }
  },
  resolve: {
    alias: {
      // '@': fileURLToPath(new URL('./src', import.meta.url))
      '@': resolve(__dirname, 'src')
    }
  },
})
